<!DOCTYPE html>
<html>
<head>
    <title>添加收费项目--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
<!--    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>-->
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>

</head>
<body>
<form id="form" action="charge.html" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">编号</td>
        <td><input class="id"  disabled="disabled"></input></td>
        <input class="id" type="hidden"  name="id"></input>
    </tr>
    <tr>
        <td width="10%" class="tableleft">收费项目名称</td>
        <td><input type="text" id="chargeName" name="chargeName" value=""/></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">收费金额</td>
        <td><input type="text" id="chargeMoney" name="chargeMoney" value=""/></td>
    </tr>
    <tr>
        <td colspan="2">
			<center>
				<button onclick="A()" type="button" class="btn btn-primary">保存</button> &nbsp;&nbsp;
                <button onclick="B()" type="button" class="btn btn-success">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
</html>
<script>

    /**
     * 获取url参数
     */
    (function ($) {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
    })(jQuery);

    function A(){
        $.ajax({
            url: "/charge/updateAdvance",
            method:"POST",
            data: $("#form").serialize(),
            dataType:"json",
            success: function(vo){
               alert(vo.msg);

                    window.location.href="/Hospital/charge.html";
            }
        })
    }

    function B(){
        window.location.href="/Hospital/charge.html";
    }
    // $.ajax({
    //     url:"/charge/info",
    //     dataType: "json",
    //     success:function (vo){
    //
    //     }
    // })

    $(function(){
        var id = $.getUrlParam("id");
        console.log(id)
        $.ajax({
            type: "GET",
            url: "/charge/getCharge?id="+id,
            success: function(res){
                var id = res.obj.id;
                var chargeName = res.obj.chargeName;
                var chargeMoney = res.obj.chargeMoney;


                $(".id").val(id);
                $("#chargeName").val(chargeName);
                $("#chargeMoney").val(chargeMoney);
            }
        });
    })





</script>